package com.nashuju.web.service.role;

import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.durcframework.core.service.CrudService;
import org.springframework.stereotype.Service;

import com.nashuju.web.dao.role.DataPermissionRoleDao;
import com.nashuju.web.entity.role.DataPermissionRole;

@Service
public class DataPermissionRoleService extends CrudService<DataPermissionRole, DataPermissionRoleDao> {


    public void saveDataPermissionRole(int dpId, List<Integer> roleIds) {
        if (dpId > 0 && CollectionUtils.isNotEmpty(roleIds)) {

            for (Integer roleId : roleIds) {
                this.save(new DataPermissionRole(dpId, roleId));
            }
        }
    }

    public void delByDpId(int dpId) {
        DataPermissionRole pojo = new DataPermissionRole();
        pojo.setDpId(dpId);
        this.del(pojo);
    }
}
